package com.siashan.toolkit.captcha.core;

import java.util.UUID;

/**
 * 图形验证码工具类
 *
 * @author siashan
 * @since v1.0.3
 **/
public class CaptchaUtil {
    /**
     * 生成UUID
     *
     * @return UUID
     */
    public static String uuid() {
        return UUID.randomUUID().toString();
    }

    /**
     * 生成CaptchaInfo对象
     *
     * @param imgBase64Str  验证码Base64字符串
     * @param uuid  UUID
     * @return CaptchaInfo对象
     */
    public static CaptchaInfo captchaInfo(String imgBase64Str, String uuid) {
        CaptchaInfo info = new CaptchaInfo();
        info.setImg(imgBase64Str);
        info.setUuid(uuid);
        return info;
    }

    /**
     * 生成CaptchaInfo对象
     *
     * @param imgBase64Str  验证码Base64字符串
     * @param uuid  UUID
     * @return CaptchaInfo对象
     * @since v1.0.5
     */
    public static CaptchaData captchaData(String imgBase64Str, String uuid,String codeText) {
        CaptchaInfo info = new CaptchaInfo();
        info.setImg(imgBase64Str);
        info.setUuid(uuid);
        CaptchaData captchaData = new CaptchaData();
        captchaData.setCaptchaInfo(info);
        captchaData.setCaptchaText(codeText);
        return captchaData;
    }
}
